package com.linkface.utils;

import android.content.Context;
import android.view.Display;
import android.view.WindowManager;

/**
 * Copyright (c) 2017-2018 LINKFACE Corporation. All rights reserved.
 */

public class LFScreenUtils {

    public static final String TAG = "LFScreenUtils";

    public static int sScreenWidth;
    public static int sScreenHeight;
    public static float sScreenDensityDpi;

    public static void initialize(Context context) {
        Display display = ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
        sScreenWidth = display.getWidth();
        sScreenHeight = display.getHeight();
        sScreenDensityDpi = context.getResources().getDisplayMetrics().densityDpi;

        LFLog.i(TAG, "sScreenWidth", sScreenWidth);
        LFLog.i(TAG, "sScreenHeight", sScreenHeight);
        LFLog.i(TAG, "sScreenDensityDpi", sScreenDensityDpi);
    }

    public static int dip2px(float dpValue) {
        return (int) (dpValue * (sScreenDensityDpi / 160));
    }

    public static float px2dip(int px) {
        return px * 160 / sScreenDensityDpi;
    }

}
